package hashset03;
/*
* 1.自定义的引用数据类型使用默认的hashCode()方法和equals()方法
*   hashCode()方法:默认是根据对象的内存地址值生成哈希值,不同对象生成的哈希值不同
*   equals()方法:默认的是比较对象的内存地址值,相同就返回true,不同就返回false
*
* */
public class Person {
    private String name;
    private int age;

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    /**
     * 为了查看hashCode方法被调用
     * @return
     */
    @Override
    public int hashCode(){
        System.out.println("hashcode方法被调用..." + this.name + "  ");
        return 0;
    }

    @Override
    public boolean equals(Object obj){
        System.out.println("equals方法被调用..." + this.name + ((Person) obj).name);
        return super.equals(obj);
    }
}
